//
//  Demo1ViewController.m
//  ATWaveAnimation
//
//  Created by 柳栗斌 on 16/8/6.
//  Copyright © 2016年 柳栗斌. All rights reserved.
//

#import "Demo1ViewController.h"
#import "ATWaveAnimateView.h"
#import "YYWeakProxy.h"

@interface Demo1ViewController ()

@property (nonatomic,strong) ATWaveAnimateView *progressView;

@property (nonatomic,strong) CADisplayLink *displayerTimer;//这也是一个计时器，用它来写没么子效果，这里改用NSTimer

@property (nonatomic,strong) NSTimer *timer;//计时器

@end

@implementation Demo1ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor=[UIColor whiteColor];
    
    self.progressView = [[ATWaveAnimateView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    self.progressView.center=CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds));
    
    self.timer = [NSTimer timerWithTimeInterval:0.1 target:[YYWeakProxy proxyWithTarget:self] selector:@selector(timerAction) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
    
    self.progressView.progress = 0.f;
    self.progressView.speed = 0.5;
    
    self.progressView.firstWaveColor = [UIColor colorWithRed:134/255.0 green:116/255.0 blue:210/255.0 alpha:1];
    self.progressView.secondWaveColor = [UIColor colorWithRed:134/255.0 green:116/255.0 blue:210/255.0 alpha:0.5];
    [self.view addSubview:self.progressView];
    
}

- (void)timerAction{
    
    if (self.progressView.progress < 1.0) {
        
        self.progressView.progress+=0.01;
    }
}

- (void)dealloc{
    
    NSLog(@"释放了：%s",__FUNCTION__);
}

@end
